import ProjectPopover from "./projectPopover"
import UserPopover from "./userPopober"
import { useNavigate } from "react-router-dom"
import axios from "../../../util/http"

function Header() {
    const navigate = useNavigate()

    async function logout() {
        await axios.post("/api/logout")
        navigate("/login")
    }

    // 返回project 首页
    function home_click() {
        navigate("/project")
    }

    return (
        <div className="header_wrap_body">
            <button className="header_button" onClick={home_click}>
                <img className="header_logo" src="/logo.png" alt=""></img>
                <h2>Pabst Admin System</h2>
            </button>
            <ProjectPopover />
            <UserPopover />
            <div onClick={logout} className="header_login_out_btn">
                退出登录
            </div>
        </div>
    )
}

export default Header
